package com.horay.springclouddemo.consumer.hystrix.client;

import com.horay.springclouddemo.common.http.ResultBody;
import com.horay.springclouddemo.consumer.hystrix.client.fallback.HystrixFallbackClient;
import com.horay.springclouddemo.consumer.hystrix.configuration.HystrixConsumerConfiguration;
import com.horay.springclouddemo.model.hystrix.Hystrix;
import com.horay.springclouddemo.model.hystrix.HystrixDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 豪猪客户端
 *
 * @author heyingcheng
 * @date 2020/3/21 14:29
 */
@FeignClient(
        value = "demo-provider-hystrix",
        qualifier = "HystrixFeignClient",
        configuration = HystrixConsumerConfiguration.class,
        fallback = HystrixFallbackClient.class
)
public interface HystrixFeignClient {

    /**
     * 新增豪猪
     *
     * @param hystrix
     * @return org.springframework.http.ResponseEntity
     * @author heyingcheng
     * @date 2020/3/21 14:17
     */
    @PostMapping("hystrix")
    ResponseEntity<ResultBody> createHystrix(Hystrix hystrix);

    /**
     * 获取豪猪
     *
     * @param id
     * @return org.springframework.http.ResponseEntity
     * @author heyingcheng
     * @date 2020/3/21 14:17
     */
    @GetMapping("hystrix/{id}")
    ResponseEntity<ResultBody> getHystrix(@PathVariable Integer id);

    /**
     * 获取豪猪集合
     *
     * @param hystrixDTO
     * @return org.springframework.http.ResponseEntity
     * @author heyingcheng
     * @date 2020/3/21 14:18
     */
    @GetMapping("hystrix/hystrixs")
    ResponseEntity<ResultBody> getHystrixs(@RequestBody HystrixDTO hystrixDTO);

    /**
     * 更新豪猪
     *
     * @param hystrix
     * @return org.springframework.http.ResponseEntity
     * @author heyingcheng
     * @date 2020/3/21 14:18
     */
    @PutMapping("hystrix")
    ResponseEntity<ResultBody> updateHystrix(Hystrix hystrix);

    /**
     * 删除豪猪
     *
     * @param id
     * @return org.springframework.http.ResponseEntity
     * @author heyingcheng
     * @date 2020/3/21 14:19
     */
    @DeleteMapping("hystrix/{id}")
    public ResponseEntity<ResultBody> deleteHystrix(@PathVariable Integer id);

}
